package com.kun.mall.order.web;

import com.kun.mall.order.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.UUID;

/**
 * @author fangkun
 * @create 2023-03-23-14:29
 */
@Controller
public class HelloController {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    @ResponseBody
    @GetMapping("/test/createOrder")
    public String testOrder(){

        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setOrderSn(UUID.randomUUID().toString());

        rabbitTemplate.convertAndSend("order-event-exchange","order.create.order",orderEntity);

        return "ok";
    }

    @GetMapping("/{page}.html")
    public String page(@PathVariable("page") String page){
        return page;
    }
}
